<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let name2 = '初始值'
        async function getUserName() {
            try {
                let name1 = await Promise.resolve('张三')
                console.log(name1)
                name2 = await Promise.reject('李四')//报错，name2 = '初始值'，未改变
                console.log(name2)//不会继续执行
                let name3 = await Promise.resolve('王五')
                console.log('name3')
            }
            catch (error) {
                console.log(error)//error = '李四'
            }
            return name2
        }
        getUserName()//返回一个promise对象，其value = '初始值'
    </script>
</body>

</html>